<?php
class ControllerDeployPrice extends Controller
{
    public function getprice()
    {

        $this->load->model('catalog/product');


        $this->data['options'] = array();


        $options_arr=array();
        foreach(array_filter($this->request->post['option']) as $key => $result){
            $option_id=$this->model_catalog_product->getProductOptionForOptions($key);
            $options_arr[$option_id]=$result;
        }


        $option_label=array();
        foreach ($this->model_catalog_product->getProductOptions($this->request->post['product_id']) as $key =>$option) {
            if(array_key_exists($option['option_id'],$options_arr)){

                    foreach($option['option_value'] as $option_value){
                        if($option_value['option_value_label']==$options_arr[$option['option_id']]){
                            $option_label[$option['option_description_label']]=$option_value['option_value_label'];
                        }
                    }
            }
        }


        $price=$this->price->getPrice($option_label);
        //按月计算
        $json['text'] = "￥" . ($price * 720) . $this->language->get('price_symbole_mon');
        $json['val'] = sprintf("%01.3f",round($price * 720,3));
        $json['val_hour'] = sprintf("%01.3f",round($price,3));
        $this->response->setOutput(json_encode($json));
    }
}

